//
//  GoodDataFrame.m
//  庐山通
//
//  Created by zcj on 15-10-26.
//  Copyright (c) 2015年 郑朝军. All rights reserved.
//

#import "GoodDataFrame.h"
#import "Grouble.h"
#import "GoodData.h"
#import "GoodInforModel.h"

// 间隙
#define margen 10
#define topImgHeitht 150
#define smallImgHeight 100

@implementation GoodDataFrame
- (void)setGoodData:(GoodData *)goodData
{
    _goodData = goodData;
    
    if (goodData.goods_image.count < 6) {
        CGFloat topImgX = margen;
        CGFloat topImgY = 0;
        CGFloat topImgW = ScreenWidth - 2 * margen;
        CGFloat topImgH = topImgHeitht;
        _topImgF = CGRectMake(topImgX, topImgY, topImgW, topImgH);
        
        CGFloat leftImgX = margen;
        CGFloat leftImgY = CGRectGetMaxY(_topImgF) + margen;
        CGFloat leftImgW = (ScreenWidth / 3) - margen * 4;
        CGFloat leftImgH = smallImgHeight;
        _leftImgF = CGRectMake(leftImgX, leftImgY, leftImgW, leftImgH);
        // 获取到第一张图片的最大的x轴
        CGFloat retweenX = CGRectGetMaxX(_leftImgF) + margen;
        CGFloat retweenY = leftImgY;
        CGFloat retweenW = leftImgW;
        CGFloat retweenH = leftImgH;
        _retweenImgF = CGRectMake(retweenX, retweenY, retweenW, retweenH);
        
        CGFloat rightImgX = CGRectGetMaxX(_retweenImgF);
        CGFloat rightImgY = retweenY;
        CGFloat rightImgW = retweenW;
        CGFloat rightImgH = retweenH;
        _rightImgF = CGRectMake(rightImgX, rightImgY, rightImgW, rightImgH);
        
        // 文字

        CGFloat shopNameX = margen;
        CGFloat shopNameY = CGRectGetMaxY(_rightImgF)+ margen * 2;
        CGFloat shopNameW = ScreenWidth - 20;
        
        CGSize shopNameWH = [goodData.goods_name boundingRectWithSize:CGSizeMake(shopNameW, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:20.0] } context:nil].size;
        _shopNameF = CGRectMake(shopNameX, shopNameY, shopNameW, shopNameWH.height);
        
        CGFloat sourceX = shopNameX + margen;
        CGFloat sourceY = CGRectGetMaxY(_shopNameF) + margen;
        CGSize sourceWH = [goodData.group_info.country sizeWithAttributes:@{NSFontAttributeName : [UIFont systemFontOfSize:20]}];
        _shopSourceF = CGRectMake(sourceX, sourceY, sourceWH.width, sourceWH.height);
        
        
        _cellH = CGRectGetMaxY(_shopSourceF) + 2 * margen;
        
    }
    
    
}
@end
